<?php
	/**
	 * 检测用户是否有未读邮件
	 */
    class CheckMail extends APIBase {
		
		public $tag = "CheckMail";
    	public $isLogin = true;
		
		public function before() {
			$this->initCacheRedis();
			$this->initMysql();
			return true;
		}
		public function logic(){
			//echo strtotime(date('Y-m-d',time()).' 00:00:00');exit;
			$playerID = $this->uid;
			$UserEmailList = $this->cache_redis->keys("hUserEmailList:$playerID:*");
			if(count($UserEmailList)>0){
				$count = count($UserEmailList);
			    if ($count) {
					$num = array();
				    for($i=0;$i<$count;$i++){ 
					    $list = $this->cache_redis->hGetAll("hUserEmailList:$playerID:".$i); 
					    if($list['uid']==$playerID && $list['readstatus']==0){
						    $num[] = $list['id'];
					    }			   
				    }
	            }
				$this->returnData(array("num"=>count($num)));
			}else{
				$this->returnData(array("num"=>0));
			}
		}
		
        public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
